//TOWN SCRIPT TEMPLATE

begintownscript;

variables;
short i, j, k, l;

body;

beginstate INIT_STATE;
	set_crime_tolerance(1);

	set_name(6,"Archmage");
	set_name(7,"Jenneke");
	set_name(8,"Thissa");
	set_name(9,"Frrrrrr");
	set_name(10,"Adrianna");
	set_name(11,"Feodoric");
	set_name(12,"Michael");

if (get_flag(8,0) == 0) {
	set_flag(8,0,1);
	force_instant_terrain_redraw();
	message_dialog("You approach Perapus Castle from the back side, having wrested the secret of the tunnel from Narayan and braved the tremendous dangers of the Perilous Path. Or something.","At any rate, the tower is quite tall and impressive, and it's very blue. It also appears unguarded. Almost entirely unguarded. You don't hear ANYTHING inside. It's a little too quiet.");
	}

break;

beginstate EXIT_STATE;
//called when the party leaves the town
	text_bubble_on_char(0,"");
	text_bubble_on_char(1,"");
	text_bubble_on_char(2,"");
	text_bubble_on_char(3,"");

break;

beginstate START_STATE;
if (get_flag(8,2) != 1)
	end();

	inc_flag(8,3,1);
	
	if (get_flag(8,3) == 10)
		message_dialog("Evidently, the _guest room_ in Perapus's castle is a prison cell. It is grimy and disgusting. Worse, it is boring. Tremendously boring. You will never get anything done in here. Maybe there's some way out.","I mean, it would be pretty stupid for the prison to include a secret passage out, or to have a lever inside the cell that opened the gates. That strains credibility. But maybe there's something....");
	if (get_flag(8,3) == 25)
		message_dialog("Huh. That's weird. There's no obvious way out. It's almost as though this prison is actually supposed to keep you stuck here.","What kind of fool built this prison, anyway? Don't they realize that heroes need to enact a daring escape? This is lame!");
	if (get_flag(8,3) >= 40) {
		set_flag(8,2,2);
		message_dialog("The door opens, and your jailer walks out, carrying a coiled whip.","");
		
		force_view_center(56,40);

		set_terrain(55,36,16);
		force_instant_terrain_redraw();
		play_sound(58);

		relocate_character(28,55,37);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));
	
		set_terrain(55,36,12);
		relocate_character(28,55,38);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));
		play_sound(59);

		relocate_character(28,55,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(28,6);
		relocate_character(28,56,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(28,4);
		relocate_character(28,56,40);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		text_bubble_on_char(28,"Rog trust you find accommodations...");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"satisfactory?");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"Heh heh heh.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"Rog make you more comfortable soon.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		force_instant_terrain_redraw();

		message_dialog("As Rog says this, he taps his whip ominously. This is surely not a good sign.","");

		text_bubble_on_char(2,"Um, I think we took a wrong turn");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(2,"");
		text_bubble_on_char(2,"at the Perilous Path.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(2,"");
		text_bubble_on_char(2,"Honest mistake. Couldn't we just go?");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(2,"");
		text_bubble_on_char(28,"Heh heh heh.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		force_instant_terrain_redraw();

		message_dialog("He taps his whip again. That's starting to get really creepy.","Just then, the door to the jail opens, and some familiar faces charge in!");

		activate_hidden_group(1);
		set_character_facing(7,6);
		set_character_facing(8,0);
		set_character_facing(9,0);
		set_character_facing(10,0);
		set_character_facing(11,0);
		set_character_facing(12,0);
		relocate_character(7,53,39);
		relocate_character(8,53,40);
		relocate_character(9,53,41);
		relocate_character(10,53,42);
		relocate_character(11,53,43);
		relocate_character(12,53,44);
		set_terrain(54,39,15);
		force_instant_terrain_redraw();
		play_sound(58);

		set_character_pose(28,2);
		set_character_pose(7,2);
		set_character_pose(8,2);
		set_character_pose(9,2);
		set_character_pose(10,2);
		set_character_pose(11,2);
		set_character_pose(12,2);
		force_instant_terrain_redraw();
		play_sound(18);

		relocate_character(7,54,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(7,55,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(7,56,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(7,4);
		set_character_pose(7,1);
		put_effect_on_char(28,12,1,2);
		run_animation_sound(70);
		set_character_pose(7,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(8,54,39);
		set_character_facing(8,6);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(8,55,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_pose(8,1);
		put_effect_on_char(28,12,1,2);
		run_animation_sound(69);
		set_character_pose(8,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(9,54,39);
		set_character_facing(9,6);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(9,55,40);
		set_character_facing(9,5);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(9,7);
		set_character_pose(9,1);
		put_effect_on_char(28,12,1,2);
		run_animation_sound(71);
		set_character_pose(9,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(10,53,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(10,7);
		relocate_character(10,54,38);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(10,6);
		set_character_pose(10,1);
		text_bubble_on_char(10,"Ice Bolt!");
		put_jagged_zap(char_loc_x(10),char_loc_y(10),char_loc_x(28),char_loc_y(28),1);
		put_boom_on_char(28,3,0);
		run_animation_sound(65);
		pause(1 * get_flag(290,0));

		text_bubble_on_char(10,"");
		set_character_pose(10,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(11,53,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(11,6);
		relocate_character(11,54,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_pose(11,1);
		text_bubble_on_char(11,"Flame!");
		put_jagged_zap(char_loc_x(11),char_loc_y(11),char_loc_x(28),char_loc_y(28),0);
		put_boom_on_char(28,0,0);
		run_animation_sound(73);

		pause(1 * get_flag(290,0));
		text_bubble_on_char(11,"");
		set_character_pose(11,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		relocate_character(12,53,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(12,5);
		relocate_character(11,54,40);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_facing(12,6);
		set_character_pose(12,1);
		text_bubble_on_char(12,"Wound!");
		put_jagged_zap(char_loc_x(12),char_loc_y(12),char_loc_x(28),char_loc_y(28),6);
		put_boom_on_char(28,1,0);
		run_animation_sound(60);

		pause(1 * get_flag(290,0));
		text_bubble_on_char(12,"");
		set_character_pose(12,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_character_pose(28,1);
		text_bubble_on_char(28,"Fire Storm!");
		put_boom_on_char(7,2,0);
		put_boom_on_char(8,2,0);
		put_boom_on_char(9,2,0);
		put_boom_on_char(10,2,0);
		put_boom_on_char(11,2,0);
		put_boom_on_char(12,2,0);
		run_animation_sound(73);

		pause(1 * get_flag(290,0));
		text_bubble_on_char(28,"");
		set_character_pose(28,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		text_bubble_on_char(12,"Wait, Fire Storm?");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(12,"");
		force_instant_terrain_redraw();

		message_dialog("Michael looks deeply puzzled.","");

		text_bubble_on_char(12,"Why does an ogre know Fire Storm?");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(12,"");
		text_bubble_on_char(28,"It scroll.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"Rog suspect it come in handy someday.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(12,"Ah. I was afraid");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"you had learned it from a book.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(12,"");
		text_bubble_on_char(28,"Rog never read book.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"Rog EAT book once.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"Rog aware that not intended purpose,");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		text_bubble_on_char(28,"but Rog seeking shortcut to wisdom.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(28,"");
		force_instant_terrain_redraw();
		pause(10 * get_flag(290,0));

		text_bubble_on_char(10,"Psst. Jenneke. Your turn.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(10,"");
		text_bubble_on_char(7,"Gods! Took long enough. I dozed off.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(7,"");
		force_instant_terrain_redraw();

		set_character_pose(7,1);
		put_effect_on_char(28,12,1,2);
		run_animation_sound(70);
		kill_char(28,2,0);
		set_character_pose(7,2);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		reset_dialog();
		add_dialog_str(0,"Thissa high-fives Jenneke. With the combat over, they arrange themselves into an orderly single-file line. They rapidly search the area. When they're done, they see you.",0);
		add_dialog_str(1,"_What do you think, Jenneke?_ Feodoric says. _Setting them free is probably worth a few XP._",0);
		add_dialog_str(2,"Jenneke shrugs. _Sure, why not?_ He shifts the chains.",0);
		run_dialog(1);

		set_character_facing(7,6);
		set_character_facing(8,6);
		set_character_facing(9,6);
		set_character_facing(10,6);
		set_character_facing(11,6);
		set_character_facing(12,6);
		set_character_pose(7,0);
		set_character_pose(8,0);
		set_character_pose(9,0);
		set_character_pose(10,0);
		set_character_pose(11,0);
		set_character_pose(12,0);
		relocate_character(7,57,39);
		relocate_character(8,56,39);
		relocate_character(9,55,39);
		relocate_character(10,54,39);
		relocate_character(11,53,39);
		relocate_character(12,52,39);
		force_instant_terrain_redraw();
		pause(1 * get_flag(290,0));

		set_terrain(55,41,30);
		set_terrain(56,41,30);
		set_terrain(57,41,30);
		force_instant_terrain_redraw();
		play_sound(99);

		message_dialog("_Darn, only 5 XP for freeing them,_ Feodoric laments. _Oh well._","They depart as quickly as they have come. This appears to be your opportunity to escape and complete your quest. Or something.");

		i = 7;
		while (i <= 12) {
			erase_char(i);
			i = i + 1;
			}

		force_view_center(char_loc_x(0),char_loc_y(0));
		force_instant_terrain_redraw();

		text_bubble_on_char(3,"Guys?");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"I think...");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(3,"");
		text_bubble_on_char(3,"we were a sidequest just then.");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(3,"");
		text_bubble_on_char(2,"I was a damsel in distress!");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(2,"");
		text_bubble_on_char(2,"*squeal!*");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(2,"");
		text_bubble_on_char(0,"*sigh*");
		force_instant_terrain_redraw();
		pause(5 * get_flag(290,0));

		text_bubble_on_char(0,"");
		force_instant_terrain_redraw();

		}

break;

beginstate 10;
if (get_terrain(55,41) == 26)
	message_dialog("This wheel is locked, and you don't have the key, like just about everything else around here.","It looks fresh and shiny, as if it has been newly cleaned or maintained. Weird.");
else
	message_dialog("These chains open and shut your prison. They've been moved to the _open_ position and broken there. They cannot do any more.","");
break;

beginstate 11;
	message_dialog("In this desk, you find the records of the Director of Guest Relations, Corporal Division (or so he signs every one of his papers). These records indicate that the jailer regularly used _implement-aided persuasion_ to make the guests feel at home.","It is a little unclear which is more disturbing: the fact that such vicious torture took place here, or the euphemistic way in which it is described in these papers.");
break;

beginstate 12;
if (get_flag(8,1) == 0) {
	set_flag(8,1,1);
	message_dialog("Well, it's pretty clear what this room was used for.","");
	}
break;

beginstate 13;
if (get_flag(8,4) != 0)
	end();
if (get_flag(8,2) == 2) {
	set_flag(8,4,1);
	
	block_entry(1);

	message_dialog("You charge into the archmage's throne room again! This time, fortune and glory for sure! Or something!!","");

	activate_hidden_group(1);
	activate_hidden_group(4);
	i = 6;
	while (i <= 12) {
		set_character_pose(i,2);
		i = i + 1;
		}
	set_character_pose(23,2);
	set_character_pose(24,2);

	march_party(32,39);
	force_view_center(32,39);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,38);
	force_view_center(32,38);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,37);
	force_view_center(32,37);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,36);
	force_view_center(32,36);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,35);
	force_view_center(32,35);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,34);
	force_view_center(32,34);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,33);
	force_view_center(32,33);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	message_dialog("It looks as though you're somewhat late to the battle. That's okay, though; you can still contribute!","You just have to wait until everybody with higher Dexterity moves. Then you'll show them! Or something!!");

	set_character_pose(7,1);
	put_effect_on_char(28,12,1,2);
	run_animation_sound(70);
	set_character_pose(7,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	set_character_pose(8,1);
	put_effect_on_char(28,12,1,2);
	run_animation_sound(69);
	set_character_pose(8,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	set_character_pose(9,1);
	put_effect_on_char(24,12,1,2);
	run_animation_sound(71);
	set_character_pose(9,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	set_character_pose(10,1);
	text_bubble_on_char(10,"Death Arrows!");
	put_jagged_zap(char_loc_x(10),char_loc_y(10),char_loc_x(6),char_loc_y(6),2);
	put_jagged_zap(char_loc_x(10),char_loc_y(10),char_loc_x(23),char_loc_y(23),2);
	put_jagged_zap(char_loc_x(10),char_loc_y(10),char_loc_x(24),char_loc_y(24),2);
	put_boom_on_char(6,3,0);
	put_boom_on_char(23,3,0);
	put_boom_on_char(24,3,0);
	run_animation_sound(73);
	kill_char(23,2,0);
	kill_char(24,2,0);
	pause(1 * get_flag(290,0));

	text_bubble_on_char(10,"");
	set_character_pose(10,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	set_character_pose(11,1);
	text_bubble_on_char(11,"Holy Scourge!");
	put_jagged_zap(char_loc_x(11),char_loc_y(11),char_loc_x(6),char_loc_y(6),2);
	put_effect_on_char(6,7,1,2);
	run_animation_sound(46);
	pause(1 * get_flag(290,0));

	text_bubble_on_char(11,"");
	set_character_pose(11,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	set_character_pose(12,1);
	text_bubble_on_char(12,"Mind Duel!");
	put_jagged_zap(char_loc_x(12),char_loc_y(12),char_loc_x(6),char_loc_y(6),6);
	put_effect_on_char(6,8,1,2);
	run_animation_sound(25);
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	play_sound(81);
	pause(1 * get_flag(290,0));
	kill_char(6,2,0);
	pause(1 * get_flag(290,0));

	text_bubble_on_char(12,"");
	set_character_pose(12,2);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	reset_dialog();
	add_dialog_str(0,"And now that it's your turn to move, you find that you can only stand in motionless silence, an eloquent statement on the futility of it all.",0);
	add_dialog_str(1,"After all, this has all been a futile effort. Not one event in the recent past has depended on you. No one has wanted to see you. No one has wanted to talk to you. No one has been interested in your story.",0);
	add_dialog_str(2,"Whenever you've gotten any adventure, it has always been Jenneke's group's sloppy seconds.",0);
	add_dialog_str(3,"To add insult to injury, when you first saw them in the inn, they were hardly any stronger than you, but now, they have mysteriously grown in power so as to totally outdistance you.",0);
	run_dialog(1);

	text_bubble_on_char(11,"Show-off.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	text_bubble_on_char(12,"What?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(12,"");
	text_bubble_on_char(11,"Killing him with Mind Duel.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	text_bubble_on_char(11,"That was completely unnecessary.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	text_bubble_on_char(11,"What did you think he was?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	text_bubble_on_char(11,"Garzahd?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	text_bubble_on_char(12,"You gotta admit,");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(12,"");
	text_bubble_on_char(12,"it was cool.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(12,"");
	text_bubble_on_char(11,"Point taken.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(11,"");
	force_instant_terrain_redraw();

	message_dialog("That's Jenneke's team. You glance back at your own.","");

	set_character_facing(0,4);

	text_bubble_on_char(1,"*scratch*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(1,"");
	text_bubble_on_char(1,"*burp*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(1,"");
	text_bubble_on_char(3,"*mutter*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(2,"*squeal!*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,0);
	text_bubble_on_char(2,"");
	text_bubble_on_char(0,"*sigh*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	force_instant_terrain_redraw();

	message_dialog("You can't compare. You were born to be heroes! You are sure of it! But in this land, with real PCs walking around, you're just not. You're nobody's heroes.","");

	erase_char(7);
	erase_char(8);
	erase_char(9);
	erase_char(10);
	erase_char(11);
	erase_char(12);
	force_instant_terrain_redraw();

	message_dialog("With not a word, not even a glance in your direction, the real heroes depart, having already gathered the XP and treasure from this battle.","You can only hope that Machrone's orb was of little enough importance that they didn't pay any attention to it. It might still be here, somewhere.");

	}

if (get_flag(8,2) == 0) {
	set_flag(8,2,1);
	message_dialog("You charge into the archmage's throne room, ready to inflict some serious damage on the evil wizard who rules this area. Fortune and glory! Or something!!","");
	
	block_entry(1);
	
	march_party(32,39);
	force_view_center(32,39);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,38);
	force_view_center(32,38);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,37);
	force_view_center(32,37);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,36);
	force_view_center(32,36);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	march_party(32,35);
	force_view_center(32,35);
	force_instant_terrain_redraw();
	pause(1 * get_flag(290,0));

	text_bubble_on_char(0,"Surrender, evil mage, or...");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(6,4);
	text_bubble_on_char(0,"");
	text_bubble_on_char(6,"Hmm?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"What was that?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(6,"");
	text_bubble_on_char(0,"Um,");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"I said, surrender, or else!");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(6,"Or else what?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(6,"");
	text_bubble_on_char(3,"Or else we'll take your evil staff");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(3,"and shove it up your...");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	force_instant_terrain_redraw();

	activate_hidden_group(2);
	put_boom_on_char(13,2,0);
	put_boom_on_char(14,2,0);
	put_boom_on_char(15,2,0);
	put_boom_on_char(16,2,0);
	put_boom_on_char(17,2,0);
	put_boom_on_char(18,2,0);
	put_boom_on_char(19,2,0);
	put_boom_on_char(20,2,0);
	run_animation_sound(10);

	activate_hidden_group(3);
	put_boom_on_char(21,0,0);
	put_boom_on_char(22,0,0);
	run_animation_sound(51);

	activate_hidden_group(4);
	put_boom_on_char(23,3,0);
	put_boom_on_char(24,3,0);
	run_animation_sound(25);

	activate_hidden_group(5);
	put_boom_on_char(25,6,0);
	put_boom_on_char(26,6,0);
	put_boom_on_char(27,6,0);
	run_animation_sound(61);

	set_character_facing(0,2);
	set_character_facing(1,2);
	set_character_facing(2,2);
	set_character_facing(3,2);
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,6);
	set_character_facing(1,6);
	set_character_facing(2,6);
	set_character_facing(3,6);
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,0);
	set_character_facing(1,0);
	set_character_facing(2,0);
	set_character_facing(3,0);
	text_bubble_on_char(3,"*gulp*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(6,"You were saying?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(6,"");
	text_bubble_on_char(3,"Er... nothing.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(3,"Sir.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(6,"That's what I thought.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Now, who the devil are you?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();

	message_dialog("You attempt to explain, but the archmage quickly interrupts you. _Never mind. I don't care. Guards, escort our guests to the guest room._","That doesn't sound so bad. You follow your escorts.");

	i = 13;
	while (i <= 27) {
		erase_char(i);
		i = i + 1;
		}

	march_party(58,45);
	march_party(57,45);
	march_party(56,45);
	march_party(55,45);
	force_view_center(55,45);
	force_instant_terrain_redraw();

	message_dialog("Then again....","");

	}
break;

beginstate 14;
if (get_terrain(54,39) == 11)
	message_dialog("This door is powerfully locked. You can't get through, no matter what you do.","");
break;

beginstate 15;
	message_dialog("You approach this book in the archmage's back room. Perhaps the great archmage has a book of arcane secrets in his secret laboratory, as any decent archmage should? You begin to read eagerly, hoping to salvage some use out of this non-adventure.","Unfortunately, this book is a copy of the Gremlinicon. Since that joke wasn't even funny the first time, there's no need to repeat it here. You sigh and quietly curse the prurient tastes of the late archmage.");
break;

beginstate 16;
	add_dialog_str(0,"With heart thundering, you open the crystal box, ready to uncover the object of your quest: Machrone's orb!",0);
	add_dialog_str(1,"Unfortunately, the box is empty.",0);
	add_dialog_str(2,"This cannot be! You frantically search the box for a false bottom, a secret compartment somewhere, and sure enough, you find one. You pop it open, and you find...",0);
	set_flag(8,6,run_dialog(1));
	message_dialog("Nothing. Not a blessed thing. Machrone's orb isn't here. And if it isn't here, the archmage doesn't have Machrone's orb at all.","It seems that there is nothing more that you can do here. It may be time to return to your dubious quest-giver.");
	toggle_quest(3,0);
	toggle_quest(4,1);
break;

beginstate 17;
if (get_flag(8,5) == 0) {
	set_flag(8,5,1);
	message_dialog("A secret passage! And if your keen adventurers' senses are as honed as you think they are, this is the archmage's secret lab! If he was keeping a stolen magic item, such as Machrone's orb, he would keep it here for sure.","Perhaps in that crystal box at the north end of the room.");
	}
break;

beginstate 18;
	message_dialog("The sign on the wall says, _Forbidden Zone! Stay out!_ Sounds like the perfect place for adventurers like yourselves to find powerful artifacts and defeat great monsters and earn loads of XP! If you can only get the door open.","Unfortunately, you can't. The door is magically locked well beyond your ability to pick, and you don't have the key. Given how this adventure is going, it may not even be possible to find the key here.");
break;

beginstate 19;
	block_entry(1);
	message_dialog("As you approach, these runes flash, and a commanding voice says in your head, _You are not authorized to pass._ You can't cross.","You suspect that these runes were designed to keep intruders out (unless they have some charm, presumably), but they're keeping you IN. You can't go out this way.");
break;

beginstate 20;
if (get_flag(8,7) == 0) {
	set_flag(8,7,1);

	text_bubble_on_char(0,"");
	text_bubble_on_char(1,"");
	text_bubble_on_char(2,"");
	text_bubble_on_char(3,"");

	message_dialog("As you approach, you notice something.","");

	text_bubble_on_char(0,"These doors look different.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(3,"Yes, the ornate wood inlay clearly...");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(2,"They're prettier!");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(2,"");
	text_bubble_on_char(3,"clearly... is prettier.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(0,"The archmage must be in here!");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"Fortune!");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(2,"Glory! *giggle*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(2,"");
	text_bubble_on_char(3,"Or something.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(1,"*burp*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(1,"");
	text_bubble_on_char(0,"*sigh*");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	force_instant_terrain_redraw();
	
	}
break;

beginstate 21;
	put_boom_on_space(40,9,1,2);
	put_boom_on_space(40,9,1,2);
	put_boom_on_space(40,9,1,2);
	put_boom_on_space(40,9,1,2);

	put_boom_on_space(40,11,1,2);
	put_boom_on_space(40,11,1,2);
	put_boom_on_space(40,11,1,2);
	put_boom_on_space(40,11,1,2);

	put_boom_on_space(40,13,1,2);
	put_boom_on_space(40,13,1,2);
	put_boom_on_space(40,13,1,2);
	put_boom_on_space(40,13,1,2);

	put_boom_on_space(40,15,1,2);
	put_boom_on_space(40,15,1,2);
	put_boom_on_space(40,15,1,2);
	put_boom_on_space(40,15,1,2);

	run_animation_sound(51);

if (char_on_loc(40,9))
	damage_char(char_on_loc(40,9),get_ran(1,1,4),1);
if (char_on_loc(40,11))
	damage_char(char_on_loc(40,11),get_ran(1,1,4),1);
if (char_on_loc(40,13))
	damage_char(char_on_loc(40,13),get_ran(1,1,4),1);
if (char_on_loc(40,15))
	damage_char(char_on_loc(40,15),get_ran(1,1,4),1);

if (get_flag(8,8) == 0) {
	set_flag(8,8,1);
	message_dialog("Woah! Impressive! Big explosion! Wonder what it's for.","You fiddle with it a bit more, and it doesn't appear that it's for anything. It just makes big explosions. Judging by the jug of cheap wine in the corner, the archmage comes to this room when he wants to get drunk and blow stuff up. Lovely.");
	}
break;

beginstate 22;
if (get_flag(8,9) == 0) {
	set_flag(8,9,1);
	reset_dialog();
	add_dialog_str(0,"As you enter this room, you see a wall of impenetrable magical fields surrounding a statue!",0);
	add_dialog_str(1,"Could it be... an awesomely powerful living statue that the archmage has trapped in here and experimented on against its will and that now has a terrible grudge against the archmage and will aid you in your quest once you free it?",0);
	add_dialog_str(2,"You look a bit closer. No. No, it's just a statue. It's not living at all. The archmage just decided to set up these impenetrable magical fields around a completely normal, bland statue.",0);
	run_dialog(1);
	}
break;

beginstate 23;
	message_dialog("This control panel presumably controls the magical fields in this room. However, it is far too complicated for you to figure out. You try pressing a few buttons at random, but nothing happens.","How useful.");
break;

beginstate 24;
if (get_flag(8,18) == 0) {
	set_flag(8,18,1);
	play_sound(172);
	message_dialog("_Woof!_ As you step in front of this window, a dog outside barks at you. You hush it, and it promptly quiets. You look out the window and see a number of puppies and kittens, not unlike the wildlife at the Perilous Path.","Adventurer's instincts take over for a moment and you check if the puppies have magical residue or are actually baby dire wolves or something, but no, the archmage is true to form: they're just normal, adorable puppies and kittens.");
	}
break;

beginstate 25;
	message_dialog("Ah! At last! A hidden case of magical goodies! Surely the archmage must store his deep, dark, secret, archmage-y things here! Though, er, there is a lock for the case. Not on the case. On the floor, several paces away.","You open the case, and sure enough, it's empty. It has a few signature scratches on it, tell-tale signs of recent looting by adventurers.");
break;

beginstate 26;
if (get_flag(8,10) == 0) {
	set_flag(8,10,1);
	message_dialog("This room appears to be used for cooking of some sort. Given the various scraps around the room, you're not sure you really want to know what's being cooked or for what purpose.","");
	}
break;

beginstate 27;
	reset_dialog();
	add_dialog_str(0,"Here's where the cooking takes place. Would you like to look in?",0);
	add_dialog_choice(0,"No. (Leave it alone.)");
	add_dialog_choice(1,"Yes. (Look inside.)");
	if (run_dialog(1) == 1)
		end();

	set_character_facing(0,6);
	text_bubble_on_char(3,"And he looks in...");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,4);
	text_bubble_on_char(3,"");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,0);
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	set_character_facing(0,2);
	text_bubble_on_char(3,"C'mon, helmet-brain,");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(3,"What'd you see?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(3,"");
	text_bubble_on_char(1,"?");
	text_bubble_on_char(2,"?");
	text_bubble_on_char(3,"?");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(1,"");
	text_bubble_on_char(2,"");
	text_bubble_on_char(3,"");
	text_bubble_on_char(0,"...");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"I don't know.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"I don't want to know.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"We're done here.");
	force_instant_terrain_redraw();
	pause(5 * get_flag(290,0));

	text_bubble_on_char(0,"");
	force_instant_terrain_redraw();
break;

beginstate 28;
	message_dialog("How do you like THEM apples?!","");
break;

beginstate 29;
if (get_flag(8,12) == 0) {
	set_flag(8,12,1);
	message_dialog("Judging by the huge pile in the corner, this is where the archmage comes when he wants to burn lots of incense. Whatever that means.","");
	}
break;

beginstate 30;
if (get_flag(8,13) == 0) {
	set_flag(8,13,1);
	message_dialog("An old, cobwebby storage room! Surely this must be where the archmage casts off old, seldom-used scrolls or tomes of arcane knowledge, where valuable information can be gleaned from the scraps!","");
	}
break;

beginstate 31;
if (get_flag(8,14) == 0) {
	set_flag(8,14,1);
	message_dialog("A secret storage room! If he didn't keep anything useful in the other room, then surely this must be where the archmage keeps what he TRULY values!","");
	}
break;

beginstate 32;
	message_dialog("On this shelf, you spot a book titled, _How to be a Mysterious Archmage Without Really Trying._ Based on what you've seen around here, this archmage has definitely taken this book's advice.","");
break;

beginstate 33;
if (get_flag(8,11) == 0) {
	set_flag(8,11,1);
	message_dialog("Hey, a secret passage! Where does it lead?","");
	}
break;

beginstate 34;
if (get_flag(8,11) == 1) {
	set_flag(8,11,2);
	
	text_bubble_on_char(0,"");
	text_bubble_on_char(0,"*sigh*");
	force_instant_terrain_redraw();
	}
break;

beginstate 35;
if (get_flag(8,15) == 0) {
	set_flag(8,15,1);
	message_dialog("A library! This must contain all the archmage's secrets to success! Your eyes immediately begin scanning the shelves eagerly.","Many of the titles look irrelevant, but surely in here there must be something of use!");
	}
break;

beginstate 36;
if (get_flag(8,16) == 0) {
	set_flag(8,16,1);
	message_dialog("Meditation cells. Somewhat dusty and clearly unused.","Huh.");
	}
break;

beginstate 37;
if (get_flag(8,17) == 0) {
	set_flag(8,17,1);
	message_dialog("In this room, there are many ornate statues and beautiful paintings, depicting figures and scenes that may be from the archmage's past! They may hold the key to... to...","No, it looks as though they're just statues and paintings. Darn it.");
	}
break;